package cn.le;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

@SuppressWarnings({ "rawtypes", "unchecked" })
public class Tool {

	private static Map message = new HashMap();;

	/**
	 * 初始化,加载配置信息
	 * @throws IOException
	 */
	public static void init() throws IOException
	{
		/*Properties prop =  new  Properties();
		InputStream in = Object. class .getResourceAsStream( "/path.properties" );
         try  {
            prop.load(in);
            Enumeration ent = prop.propertyNames();
            while (ent.hasMoreElements()) {
            	String key = ent.nextElement().toString().trim();
             	String value = prop.getProperty(key).trim().replace("\\", "/");
             	message.put(key, value);
			}
         }  catch  (IOException e) {
        	 e.printStackTrace();
         }    */
		BufferedReader bReader = new BufferedReader(new FileReader(new File("F:\\Individual\\JavaCode\\filejnotify\\src\\main\\resources\\param.txt")));
		while(true)
		{
			String str = bReader.readLine();
			if(str == null)
			{
				break;
			}
			String[] strs = str.split("=");
			message.put(strs[0], strs[1]);
		}
		bReader.close();
	}
	/**
	 * 获取配置信息
	 * @param key
	 * @return
	 */
	public static String load(String key)
	{
		return (String) message.get(key);
	}
	/**
	 * 清除
	 */
	public static void close()
	{
		message = null;
	}
}
